package shuimin.weixin.message.model;

import pond.common.S;
import pond.db.Model;

import java.util.Map;

/**
 * Created by sky on 16/5/17.
 */
public abstract class AMessage extends Model{

    protected Map<String,Object> message;

    private AMessage(){}

    public AMessage(Map<String, Object> message){
        this.message=message;
    }

    public Map<String, Object> getMessage() {
        return message;
    }

    public String getFromUser() {
        return String.valueOf(message.get("FromUserName"));
    }

    public String getToUser() {
        return String.valueOf(message.get("ToUserName"));
    }

    public String getCreateTime() {
        return String.valueOf(message.get("CreateTime"));
    }

    public String getMsgId() {
        return String.valueOf(message.get("MsgId"));
    }

    public void reply(AMessage replyContent){
        replyContent.getMessage().put("FromUserName", this.getToUser());
        replyContent.getMessage().put("ToUserName", this.getFromUser());
        replyContent.getMessage().put("CreateTime", S.now());
        replyContent.getMessage().put("MsgId", this.getMsgId());
    }

}
